using System;

namespace TextEditor
{
    public class A_FontUnderline : A_Action
    {
        public override string ActionName()
        {
            return "underline";
        }

        public override int CheckState()
        {
            ZYTextChar myChar = base.myOwnerDocument.Content.GetPreChar();
            if (myChar != null)
            {
                return (myChar.FontUnderLine ? 1 : 0);
            }
            return -1;
        }

        public override A_Action Clone()
        {
            A_FontUnderline f = new A_FontUnderline();
            f.BaseCloneFrom(this);
            return f;
        }

        public override bool Execute()
        {
            ZYTextChar preChar = base.myOwnerDocument.Content.GetPreChar();
            if (preChar != null)
                base.myOwnerDocument.SetSelectionUnderLine(!preChar.FontUnderLine);
            return true;
        }

        public override bool isEnable()
        {
            return base.myOwnerDocument.CanModify();
        }
    }
}
